<template>
    <div>

        <h1>医生信息显示</h1>
        <a href="/addys">添加医生信息</a> 
        <br>
         <a href="/">病房信息</a>
         <br>
          <a href="/show">科室信息</a>
          <br>
        <table class="table">
            <thead>
                <tr>
                    <td>医生编号</td>
                    <td>医生姓名</td>
                    <td>所属科室</td>
                    <td>头像</td> 
                    <td>创建日期</td> 
                </tr>
            </thead>
            <tbody>
                 <tr v-for="e in data">
                    <td>{{ e.id }}</td>
                    <td>{{ e.doctorName }}</td>
                    <td>{{ e.departName }}</td>
                    <td><img :src="'https://localhost:7125/'+e.imgUrl" style="height: 60px; width: 60px;"></td> 
                    <td>{{ moment(e.doctorDate).format("YYYY-MM-DD") }}</td>  
                </tr>
            </tbody>
        </table>
        一共{{pageinfo.listcount}}页,一共{{pageinfo.count}}条,当前第{{page.pageIndex}}页,每页显示第{{page.pageSize}}条
        <input type="button" value="首页" @click="dianji(1)">
        <input type="button" value="下一页" @click="dianji(2)">
        <input v-for="e in pageinfo.listcount" type="button" :value="e" @click="dj(e)">
        <input type="button" value="上一页" @click="dianji(3)">
        <input type="button" value="尾页" @click="dianji(4)">
        <input type="text" v-model="page.pageIndex"><input type="button" value="跳转" @click="tz">
        <select v-model="page.pageSize" @change="yrl">
            <option :value="3">3</option>
            <option :value="5">5</option>
            <option :value="8">8</option>
        </select>
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue'
import axios from 'axios'
import moment from 'moment';
import { useRouter } from 'vue-router'

const router=useRouter();
onMounted(()=>{
    show();
})

const yrl=()=>{
    show();
}

const dj=(val:any)=>{
    page.value.pageIndex=val 
    show();
}

const tz=()=>{
    show();
}

const dianji=(val:any)=>{
   if(val==1)
   {
    page.value.pageIndex=1;
   }
   if(val==2)
   {
    if(page.value.pageIndex<pageinfo.value.listcount)
   {
        page.value.pageIndex+=1
   }
   }
   if(val==3)
   {
   if(page.value.pageIndex>1)
   {
        page.value.pageIndex-=1
   }
   }
   if(val==4)
   {
    page.value.pageIndex=pageinfo.value.listcount;
   }
show();
}

 

const data =ref([{
     "id": 1,
      "departid": 1,
      "doctorName": "张三",
      "imgUrl": "string",
      "doctorDate": "2025-05-13T12:17:15.181",
      "departName": "内科"
  }])
 

const page =ref({   
    pageIndex:1,
    pageSize:3,
  })
const pageinfo =ref({   
    count:0,
    listcount:0
  })
const show =()=>{
    axios.get("/api/Doctor/ShowDoctor",{params:page.value}).then(res=>{
        data.value=res.data.listcount
        pageinfo.value.count=res.data.count
        pageinfo.value.listcount=Math.ceil(pageinfo.value.count/page.value.pageSize)
    })
}

</script>

<style scoped>

</style>    